<template>
  <view class="main_box">
    <view class="flex tab_box">
      <view :class="selectIndex === 0 ? 'select' : 'not_select'" style="margin-right: 30rpx" @tap="changeSelect(0)">基本信息</view>
      <view :class="selectIndex === 1 ? 'select' : 'not_select'" @tap="changeSelect(1)">更多信息</view>
    </view>
    <view v-show="selectIndex === 0" class="base_info_box">
      <goods-ls v-for="item in info_list" style="height: 120rpx" :label="item.name" :type="item.type" v-model="curGoods[item.value]" :isScan="item.isScan" :select-params="item.selectParams" @selectCallBack="selectCallBack" />
      <!-- <image :src="images.length?images[0].path:'/static/add.png'" style="width: 100%" @tap="photo"/> -->
    </view>
    <view v-show="selectIndex === 1" class="more_info_box">
      <goods-ls v-for="item in more_list" :label="item.name" :type="item.type" style="height: 120rpx" v-model="curGoods[item.value]" :isScan="item.isScan" :select-params="item.selectParams" @selectCallBack="item.selectCallBack" />
      <view class="flex">
        <goods-ls label="质保期" style="margin-right: 20rpx; height: 120rpx" type="input" v-model="curGoods.expiration" />
        <picker mode="selector" style="height: 120rpx" :range="expirationUnitList" @change="changeExpiration" range-key="name">
          <view class="picker"> {{ expirationUnitMap[curGoods.expirationUnit] ? expirationUnitMap[curGoods.expirationUnit] : '请选择' }}</view>
        </picker>
        <!-- <goods-ls
          label=""
          style="height: 120rpx"
          type="select"
          v-model="expirationUnitMap[curGoods.expirationUnit]"
          :select-params="{
            list: expirationUnitList,
            multiple: false,
            filterable: true,
            name:'expiration'
          }"
          @selectCallBack="selectExpirationUnit" -->
        <!-- /> -->
      </view>
      <view class="flex">
        <goods-ls label="一级单位" style="margin-right: 20rpx; height: 120rpx" type="select" v-model="curGoods.firstUnitName" :select-params="unitParams" @selectCallBack="e => selectUnit('firstUnitId', 'firstUnitName', e)" />
        <goods-ls label="一级单位数量" style="height: 120rpx" type="input" v-model.sync="curGoods.firstUnitCount" />
      </view>
      <view class="flex">
        <goods-ls label="二级单位" style="margin-right: 20rpx; height: 120rpx" type="select" v-model="curGoods.secondUnitName" :select-params="unitParams" @selectCallBack="e => selectUnit('secondUnitId', 'secondUnitName', e)" />
        <goods-ls label="二级单位数量" style="height: 120rpx" type="input" v-model.sync="curGoods.secondUnitCount" />
      </view>
    </view>
    <view class="save_box">
      <view class="save" @tap="save"> 保存 </view>
    </view>
  </view>
</template>

<script>
import { appBasGoods, appBasGoodsAddOrSave, basGoodsListForAdd } from '@/service/api/common_down'
import GoodsLs from '@/components/goods-ls.vue'
import ProxyGoods from '@/models/proxyGoods'

export default {
  name: 'goodsDetail',
  components: { GoodsLs },
  data() {
    return {
      curGoods: {
        goodsName: '',
      },
      priceTypeMap: {
        SINGLE: '单品',
        BOX: '箱',
      },
      expirationUnitMap: {
        DAY: '天',
        WEEK: '周',
        MONTH: '月',
        YEAR: '年',
      },
      expirationUnitList: [
        { id: 'DAY', name: '天' },
        { id: 'WEEK', name: '周' },
        { id: 'MONTH', name: '月' },
        { id: 'YEAR', name: '年' },
      ],
      unitParams: {
        url: '/api/dropDown/basUnitList',
        multiple: false,
        filterable: true,
        // warehouseId:'',
        // locationId:'',
        name: '',
      },
      info_list: [
        {
          type: 'input',
          name: '商品名称',
          value: 'name',
        },
        {
          type: 'input',
          name: '编码',
          value: 'code',
        },
        {
          type: 'input',
          name: '条形码',
          value: 'barcode',
          isScan: true,
        },
        {
          type: 'input',
          name: '箱装条形码',
          value: 'boxBarcode',
          isScan: true,
        },
        {
          type: 'input',
          name: '助记符',
          value: 'helpSign',
        },
        {
          type: 'input',
          name: '拼音',
          value: 'spell',
        },
        {
          type: 'select',
          name: '税率',
          value: 'taxName',
          selectCallBack: e => {
            console.log('e=' + e)

            // this.$set(this.curGoods,'taxId',type.id)
            // this.$set(this.curGoods,'taxName',type.name)
          },
          selectParams: {
            url: '/api/dropDown/basTaxList',
            multiple: false,
            filterable: true,
            name: 'rate',
          },
        },
        {
          type: 'input',
          name: '规格型号',
          value: 'model',
        },
        {
          name: '商品分类',
          value: 'goodsTypeName',
          type: 'select',
          selectCallBack: e => {
            console.log('e=' + JSON.stringify(e))
            // const type = e[0];
            // this.$set(this.curGoods,'goodsTypeId',type.id)
            // this.$set(this.curGoods,'goodsTypeName',type.name)
          },
          selectParams: {
            url: '/api/dropDown/childBasGoodsTypeList',
            multiple: false,
            filterable: true,
            name: 'goodsType',
          },
        },
        {
          name: '商品品牌',
          value: 'goodsBrandName',
          type: 'select',
          selectCallBack: e => {
            // const type = e[0];
            // this.$set(this.curGoods,'goodsBrandId',type.id)
            // this.$set(this.curGoods,'goodsBrandName',type.name)
          },
          selectParams: {
            url: '/api/dropDown/basGoodsBrandList',
            multiple: false,
            filterable: true,
            name: 'brandName',
          },
        },
      ],
      more_list: [
        {
          type: 'input',
          name: '采购价',
          value: 'buyTaxPrice',
        },
        {
          type: 'input',
          name: '采购箱价',
          value: 'buyTaxBoxPrice',
        },
        {
          type: 'input',
          name: '基础销售价',
          value: 'saleTaxPrice',
        },
        {
          type: 'input',
          name: '基础销售箱价',
          value: 'saleTaxBoxPrice',
        },
        {
          type: 'input',
          name: '新品标准期限(月)',
          value: 'newGoodsExpir',
        },
        {
          name: '默认仓库',
          value: 'warehouseName',
          type: 'select',
          selectCallBack: e => {
            // const type = e[0];
            // this.$set(this.curGoods,'warehouseId',type.id)
            // this.$set(this.curGoods,'warehouseName',type.name)
          },
          selectParams: {
            url: '/api/dropDown/basWarehouseList',
            multiple: false,
            filterable: true,
            name: 'warehouse',
          },
        },
        {
          name: '默认库区',
          value: 'locationName',
          type: 'select',
          selectCallBack: e => {
            // const type = e[0];
            // this.$set(this.curGoods,'locationId',type.id)
            // this.$set(this.curGoods,'locationName',type.name)
          },
          selectParams: {
            url: '/api/dropDown/basStorehouseList',
            multiple: false,
            filterable: true,
            // warehouseId:this.curGoods.warehouseId,
            name: 'locationName',
          },
        },
        {
          name: '默认库位',
          value: 'storehouseName',
          type: 'select',
          selectCallBack: e => {
            // const type = e[0];
            // this.$set(this.curGoods,'storehouseId',type.id)
            // this.$set(this.curGoods,'storehouseName',type.name)
          },
          selectParams: {
            url: '/api/dropDown/basStorehouseList',
            multiple: false,
            filterable: true,
            // warehouseId:this.curGoods.warehouseId,
            // locationId:this.curGoods.locationId,
            name: 'storehouseName',
          },
        },
      ],
      selectIndex: 0,
      images: [],
    }
  },
  onLoad(e) {
    if (e.goodsId === 'ADD') {
      this.curGoods = {
        barcode: '',
        bomInfo: '',
        bomInfoList: [
          {
            goodsCode: '',
            goodsCount: 0,
            goodsId: 0,
            goodsName: '',
            model: '',
          },
        ],
        boxBarcode: '',
        boxUnitCode: '',
        boxUnitCount: 0,
        boxUnitId: 0,
        boxUnitName: '',
        buyNoTaxBoxPrice: 0,
        buyNoTaxPrice: 0,
        buySaleType: '',
        buyTaxBoxPrice: 0,
        buyTaxPrice: 0,
        code: '',
        commonName: '',
        costNoTaxPrice: 0,
        costTaxPrice: 0,
        createTime: '',
        createUserCode: '',
        createUserId: 0,
        createUserName: '',
        customerCode: '',
        customerId: 0,
        customerName: '',
        dailyQuotaCount: 0,
        dailyQuotaCountTotal: 0,
        dailyRemainCount: 0,
        dailySoldCount: 0,
        emptyBoxGoodsCode: '',
        emptyBoxGoodsId: 0,
        emptyBoxGoodsName: '',
        existNum: 0,
        expiration: 0,
        expirationUnit: '',
        firstUnitCode: '',
        firstUnitCount: 0,
        firstUnitId: 0,
        firstUnitName: '',
        fourthUnitCode: '',
        fourthUnitCount: 0,
        fourthUnitId: 0,
        fourthUnitName: '',
        goodsBrandCode: '',
        goodsBrandId: 0,
        goodsBrandName: '',
        goodsLevel: '',
        goodsTagCode: '',
        goodsTagId: 0,
        goodsTagName: '',
        goodsTypeCode: '',
        goodsTypeId: 0,
        goodsTypeName: '',
        goodsTypeSeq: 0,
        height: 0,
        helpSign: '',
        id: 0,
        imageUrl: '',
        isAdvance: 0,
        isAppletSale: 0,
        isBatchManage: 0,
        isBulk: 0,
        isEstimate: 0,
        isExpirationManage: 0,
        isPromotion: 0,
        isRecommend: 0,
        isStorehouseManage: 0,
        latestBuyNoTaxBoxPrice: 0,
        latestBuyNoTaxPrice: 0,
        latestBuyTaxBoxPrice: 0,
        latestBuyTaxPrice: 0,
        latestCustomerCode: '',
        latestCustomerId: 0,
        latestCustomerName: '',
        latestPromotionNoTaxBoxPrice: 0,
        latestPromotionNoTaxPrice: 0,
        latestPromotionTaxBoxPrice: 0,
        latestPromotionTaxPrice: 0,
        latestSaleNoTaxBoxPrice: 0,
        latestSaleNoTaxPrice: 0,
        latestSaleTaxBoxPrice: 0,
        latestSaleTaxPrice: 0,
        length: 0,
        locationCode: '',
        locationId: 0,
        locationName: '',
        mainUnitCode: '',
        mainUnitCount: 0,
        mainUnitId: 0,
        mainUnitName: '',
        maxStock: 0,
        mdId: '',
        minReturnUnitCode: '',
        minReturnUnitCount: 0,
        minReturnUnitId: 0,
        minReturnUnitName: '',
        minSaleUnitCode: '',
        minSaleUnitCount: 0,
        minSaleUnitId: 0,
        minSaleUnitName: '',
        minStock: 0,
        model: '',
        name: '',
        newGoodsExpir: 0,
        newGoodsExpirDate: '',
        packageType: '',
        paperEmptyBoxGoodsInfo: {
          barcode: '',
          billTaxBoxPrice: 0,
          billTaxPrice: 0,
          bomMinGoodsCount: 0,
          boxBarcode: '',
          boxCount: 0,
          boxNum: 0,
          boxUnitCode: '',
          boxUnitCount: 0,
          boxUnitId: 0,
          boxUnitName: '',
          buyNoTaxBoxPrice: 0,
          buyNoTaxPrice: 0,
          buyTaxBoxPrice: 0,
          buyTaxPrice: 0,
          commonName: '',
          costNoTaxPrice: 0,
          costTaxPrice: 0,
          cutOffGoodsCount: 0,
          dailyQuotaCount: 0,
          dailyRemainCount: 0,
          dailySoldCount: 0,
          effectGoodsCount: 0,
          emptyBoxGoodsCode: '',
          emptyBoxGoodsId: 0,
          emptyBoxGoodsInfo: {
            barcode: '',
            billTaxBoxPrice: 0,
            billTaxPrice: 0,
            bomMinGoodsCount: 0,
            boxBarcode: '',
            boxCount: 0,
            boxNum: 0,
            boxUnitCode: '',
            boxUnitCount: 0,
            boxUnitId: 0,
            boxUnitName: '',
            buyNoTaxBoxPrice: 0,
            buyNoTaxPrice: 0,
            buyTaxBoxPrice: 0,
            buyTaxPrice: 0,
            commonName: '',
            costNoTaxPrice: 0,
            costTaxPrice: 0,
            cutOffGoodsCount: 0,
            dailyQuotaCount: 0,
            dailyRemainCount: 0,
            dailySoldCount: 0,
            effectGoodsCount: 0,
            emptyBoxGoodsCode: '',
            emptyBoxGoodsId: 0,
            emptyBoxGoodsInfo: {},
            emptyBoxGoodsName: '',
            existBoxCount: 0,
            existBoxNum: 0,
            existMainNum: 0,
            existNum: 0,
            firstUnitCode: '',
            firstUnitCount: 0,
            firstUnitId: 0,
            firstUnitName: '',
            fourthUnitCode: '',
            fourthUnitCount: 0,
            fourthUnitId: 0,
            fourthUnitName: '',
            giftId: 0,
            giftPromotionInfoList: [
              {
                isPromotion: 0,
                promotionCode: '',
                promotionEndDate: '',
                promotionId: 0,
                promotionName: '',
                promotionRemark: '',
                promotionStartDate: '',
                promotionType: '',
              },
            ],
            giftRemark: '',
            giftType: '',
            goodsBrandCode: '',
            goodsBrandId: 0,
            goodsBrandName: '',
            goodsCode: '',
            goodsCount: 0,
            goodsId: 0,
            goodsLevel: '',
            goodsName: '',
            goodsTagCode: '',
            goodsTagId: 0,
            goodsTagName: '',
            goodsTypeCode: '',
            goodsTypeId: 0,
            goodsTypeName: '',
            goodsTypeSeq: 0,
            height: 0,
            helpSign: '',
            imageUrl: '',
            isAdvance: 0,
            isBatchManage: 0,
            isEstimate: 0,
            isPromotion: 0,
            isRecommend: 0,
            isSingleGiftPromotionWithSingleGiftGoods: 0,
            length: 0,
            locationCode: '',
            locationId: 0,
            locationName: '',
            mainNum: 0,
            mainUnitCode: '',
            mainUnitCount: 0,
            mainUnitId: 0,
            mainUnitName: '',
            minReturnUnitCode: '',
            minReturnUnitCount: 0,
            minReturnUnitId: 0,
            minReturnUnitName: '',
            minSaleUnitCode: '',
            minSaleUnitCount: 0,
            minSaleUnitId: 0,
            minSaleUnitName: '',
            mobileOrderIsAllowModifyGoodsTag: '',
            mobileOrderIsAllowModifyTaxPrice: '',
            mobileOrderIsAllowShowMainUnit: '',
            mobileOrderIsAllowShowStock: '',
            mobileOrderIsAllowShowTaxPrice: '',
            model: '',
            noTaxBoxPrice: 0,
            noTaxPrice: 0,
            oldNoTaxBoxPrice: 0,
            oldNoTaxPrice: 0,
            oldTaxBoxPrice: 0,
            oldTaxPrice: 0,
            packageType: '',
            pickBoxCount: 0,
            pickBoxNum: 0,
            pickMainNum: 0,
            pickNum: 0,
            priceType: '',
            promotionBomGoodsList: [{}],
            promotionCode: '',
            promotionEndDate: '',
            promotionId: 0,
            promotionName: '',
            promotionNoTaxBoxPrice: 0,
            promotionNoTaxPrice: 0,
            promotionRemark: '',
            promotionRuleList: [
              {
                createTime: '',
                createUserCode: '',
                createUserId: 0,
                createUserName: '',
                full: 0,
                id: 0,
                isLast: 0,
                orderCode: '',
                orderId: 0,
                reachType: 0,
                reachWay: 0,
                remark: '',
                result: 0,
                resultType: 0,
                seq: 0,
                updateTime: '',
                updateUserCode: '',
                updateUserId: 0,
                updateUserName: '',
              },
            ],
            promotionStartDate: '',
            promotionTaxBoxPrice: 0,
            promotionTaxPrice: 0,
            promotionType: '',
            remark: '',
            saleNoTaxBoxPrice: 0,
            saleNoTaxPrice: 0,
            saleTaxBoxPrice: 0,
            saleTaxPrice: 0,
            secondUnitCode: '',
            secondUnitCount: 0,
            secondUnitId: 0,
            secondUnitName: '',
            sourceDetailType: '',
            spell: '',
            startSaleGoodsCount: 0,
            status: 0,
            stockInfo: [
              {
                existBoxNum: 0,
                existMainNum: 0,
                existNum: 0,
                goodsId: 0,
                pickBoxNum: 0,
                pickMainNum: 0,
                pickNum: 0,
                usableBoxNum: 0,
                usableMainNum: 0,
                usableNum: 0,
                warehouseCode: '',
                warehouseId: 0,
                warehouseName: '',
              },
            ],
            storehouseCode: '',
            storehouseId: 0,
            storehouseName: '',
            taxBoxPrice: 0,
            taxCode: '',
            taxId: 0,
            taxName: '',
            taxPrice: 0,
            taxRate: 0,
            thirdUnitCode: '',
            thirdUnitCount: 0,
            thirdUnitId: 0,
            thirdUnitName: '',
            unGiftBoxCount: 0,
            unGiftBoxNum: 0,
            unGiftGoodsCount: 0,
            unGiftMainNum: 0,
            usableBoxCount: 0,
            usableBoxNum: 0,
            usableMainNum: 0,
            usableNum: 0,
            volume: 0,
            warehouseCode: '',
            warehouseId: 0,
            warehouseName: '',
            weight: 0,
            width: 0,
          },
          emptyBoxGoodsName: '',
          existBoxCount: 0,
          existBoxNum: 0,
          existMainNum: 0,
          existNum: 0,
          firstUnitCode: '',
          firstUnitCount: 0,
          firstUnitId: 0,
          firstUnitName: '',
          fourthUnitCode: '',
          fourthUnitCount: 0,
          fourthUnitId: 0,
          fourthUnitName: '',
          giftId: 0,
          giftPromotionInfoList: [
            {
              isPromotion: 0,
              promotionCode: '',
              promotionEndDate: '',
              promotionId: 0,
              promotionName: '',
              promotionRemark: '',
              promotionStartDate: '',
              promotionType: '',
            },
          ],
          giftRemark: '',
          giftType: '',
          goodsBrandCode: '',
          goodsBrandId: 0,
          goodsBrandName: '',
          goodsCode: '',
          goodsCount: 0,
          goodsId: 0,
          goodsLevel: '',
          goodsName: '',
          goodsTagCode: '',
          goodsTagId: 0,
          goodsTagName: '',
          goodsTypeCode: '',
          goodsTypeId: 0,
          goodsTypeName: '',
          goodsTypeSeq: 0,
          height: 0,
          helpSign: '',
          imageUrl: '',
          isAdvance: 0,
          isBatchManage: 0,
          isEstimate: 0,
          isPromotion: 0,
          isRecommend: 0,
          isSingleGiftPromotionWithSingleGiftGoods: 0,
          length: 0,
          locationCode: '',
          locationId: 0,
          locationName: '',
          mainNum: 0,
          mainUnitCode: '',
          mainUnitCount: 0,
          mainUnitId: 0,
          mainUnitName: '',
          minReturnUnitCode: '',
          minReturnUnitCount: 0,
          minReturnUnitId: 0,
          minReturnUnitName: '',
          minSaleUnitCode: '',
          minSaleUnitCount: 0,
          minSaleUnitId: 0,
          minSaleUnitName: '',
          mobileOrderIsAllowModifyGoodsTag: '',
          mobileOrderIsAllowModifyTaxPrice: '',
          mobileOrderIsAllowShowMainUnit: '',
          mobileOrderIsAllowShowStock: '',
          mobileOrderIsAllowShowTaxPrice: '',
          model: '',
          noTaxBoxPrice: 0,
          noTaxPrice: 0,
          oldNoTaxBoxPrice: 0,
          oldNoTaxPrice: 0,
          oldTaxBoxPrice: 0,
          oldTaxPrice: 0,
          packageType: '',
          pickBoxCount: 0,
          pickBoxNum: 0,
          pickMainNum: 0,
          pickNum: 0,
          priceType: '',
          promotionBomGoodsList: [{}],
          promotionCode: '',
          promotionEndDate: '',
          promotionId: 0,
          promotionName: '',
          promotionNoTaxBoxPrice: 0,
          promotionNoTaxPrice: 0,
          promotionRemark: '',
          promotionRuleList: [
            {
              createTime: '',
              createUserCode: '',
              createUserId: 0,
              createUserName: '',
              full: 0,
              id: 0,
              isLast: 0,
              orderCode: '',
              orderId: 0,
              reachType: 0,
              reachWay: 0,
              remark: '',
              result: 0,
              resultType: 0,
              seq: 0,
              updateTime: '',
              updateUserCode: '',
              updateUserId: 0,
              updateUserName: '',
            },
          ],
          promotionStartDate: '',
          promotionTaxBoxPrice: 0,
          promotionTaxPrice: 0,
          promotionType: '',
          remark: '',
          saleNoTaxBoxPrice: 0,
          saleNoTaxPrice: 0,
          saleTaxBoxPrice: 0,
          saleTaxPrice: 0,
          secondUnitCode: '',
          secondUnitCount: 0,
          secondUnitId: 0,
          secondUnitName: '',
          sourceDetailType: '',
          spell: '',
          startSaleGoodsCount: 0,
          status: 0,
          stockInfo: [
            {
              existBoxNum: 0,
              existMainNum: 0,
              existNum: 0,
              goodsId: 0,
              pickBoxNum: 0,
              pickMainNum: 0,
              pickNum: 0,
              usableBoxNum: 0,
              usableMainNum: 0,
              usableNum: 0,
              warehouseCode: '',
              warehouseId: 0,
              warehouseName: '',
            },
          ],
          storehouseCode: '',
          storehouseId: 0,
          storehouseName: '',
          taxBoxPrice: 0,
          taxCode: '',
          taxId: 0,
          taxName: '',
          taxPrice: 0,
          taxRate: 0,
          thirdUnitCode: '',
          thirdUnitCount: 0,
          thirdUnitId: 0,
          thirdUnitName: '',
          unGiftBoxCount: 0,
          unGiftBoxNum: 0,
          unGiftGoodsCount: 0,
          unGiftMainNum: 0,
          usableBoxCount: 0,
          usableBoxNum: 0,
          usableMainNum: 0,
          usableNum: 0,
          volume: 0,
          warehouseCode: '',
          warehouseId: 0,
          warehouseName: '',
          weight: 0,
          width: 0,
        },
        pickNum: 0,
        priceSuitList: [
          {
            goodsId: 0,
            noTaxBoxPrice: 0,
            noTaxPrice: 0,
            priceSuitCode: '',
            priceSuitDetailId: 0,
            priceSuitId: 0,
            priceSuitName: '',
            taxBoxPrice: 0,
            taxPrice: 0,
          },
        ],
        priceType: '',
        remark: '',
        safeStock: 0,
        saleNoTaxBoxPrice: 0,
        saleNoTaxPrice: 0,
        saleTaxBoxPrice: 0,
        saleTaxPrice: 0,
        scustomerCode: '',
        scustomerId: 0,
        scustomerName: '',
        secondUnitCode: '',
        secondUnitCount: 0,
        secondUnitId: 0,
        secondUnitName: '',
        seq: 0,
        sourceType: '',
        spell: '',
        standardBoxCount: 0,
        startSaleGoodsCount: 0,
        status: 0,
        stockInfo: [
          {
            existBoxNum: 0,
            existMainNum: 0,
            existNum: 0,
            goodsId: 0,
            pickBoxNum: 0,
            pickMainNum: 0,
            pickNum: 0,
            usableBoxNum: 0,
            usableMainNum: 0,
            usableNum: 0,
            warehouseCode: '',
            warehouseId: 0,
            warehouseName: '',
          },
        ],
        storehouseCode: '',
        storehouseId: 0,
        storehouseName: '',
        taxCode: '',
        taxId: 0,
        taxName: '',
        taxNo: '',
        taxRate: 0,
        thirdUnitCode: '',
        thirdUnitCount: 0,
        thirdUnitId: 0,
        thirdUnitName: '',
        type: 0,
        updateTime: '',
        updateUserCode: '',
        updateUserId: 0,
        updateUserName: '',
        usableNum: 0,
        volume: 0,
        warehouseCode: '',
        warehouseId: 0,
        warehouseName: '',
        weight: 0,
        width: 0,
      }
    } else {
      if (!e.goodsId) throw error('商品id不能为空')
      appBasGoods({ goodsIds: e.goodsId }).then(res => {
        console.log('=================')
        if (res.content.length) {
          this.curGoods = new ProxyGoods(res.content[0])
          // this.curGoods.priceTypeName = this.priceTypeMap[this.curGoods.priceType]
          if (this.curGoods.imageUrl) {
            this.images = JSON.parse(this.curGoods.imageUrl)
          }
        }
      })
    }
  },
  created() {},
  methods: {
    changeExpiration(e) {
      const index = e.target.value * 1
      this.curGoods.expirationUnit = this.expirationUnitList[index].id
    },
    toBack() {
      uni.navigateBack({ delta: 1 })
    },
    selectUnit(id, name, val) {
      const item = val[0]
      this.$set(this.curGoods, id, item.id)
      this.$set(this.curGoods, name, item.name)
    },
    changeSelect(index) {
      this.selectIndex = index
    },
    photo() {
      camera(e => {
        this.$set(this.images, 0, { path: e })
      })
    },
    selectExpirationUnit(e) {
      // this.curGoods.expirationUnit = e[0].id
      this.changeBaseUnitNum()
    },
    //改变基础单位计量数
    changeBaseUnitNum() {
      const unitList = ['fourthUnitCount', 'thirdUnitCount', 'secondUnitCount', 'firstUnitCount']
      this.curGoods.boxUnitCount = unitList.some(item => this.curGoods[item])
    },
    async save() {
      await appBasGoodsAddOrSave(this.curGoods)
        .then(res => {})
        .catch(err => {
          uni.showToast({
            title: err.msg,
            icon: 'none',
          })
        })
    },
    selectCallBack(data) {
      console.log('item=' + JSON.stringify(data))
      const type = data.item
      if (data.name === 'rate') {
        this.$set(this.curGoods, 'taxId', type.id)
        this.$set(this.curGoods, 'taxName', type.name)
        // this.info_list[0].value = type.name
      } else if (data.name === 'goodsType') {
        this.$set(this.curGoods, 'goodsTypeId', type.id)
        this.$set(this.curGoods, 'goodsTypeName', type.name)
      } else if (data.name === 'brandName') {
        this.$set(this.curGoods, 'goodsBrandId', type.id)
        this.$set(this.curGoods, 'goodsBrandName', type.name)
      } else if (data.name === 'warehouse') {
        this.$set(this.curGoods, 'warehouseId', type.id)
        this.$set(this.curGoods, 'warehouseName', type.name)
      } else if (data.name === 'locationName') {
        this.$set(this.curGoods, 'locationId', type.id)
        this.$set(this.curGoods, 'locationName', type.name)
      } else if (data.name === 'storehouseName') {
        this.$set(this.curGoods, 'storehouseId', type.id)
        this.$set(this.curGoods, 'storehouseName', type.name)
      }
    },
  },
}
</script>
<style scoped lang="scss">
.main_box {
  display: flex;
  flex-direction: column;
  .image_tile {
    position: relative;
    z-index: 1;
    .app_bar {
      position: absolute;
      top: 88rpx;
      left: 0;
      padding-left: 38rpx;
      .title_text {
        width: 674rpx;
        font-weight: 600;
        font-size: 36rpx;
        color: #fff;
      }
    }
    img {
      width: 750rpx;
      height: 680rpx;
    }
  }
  .goods_content {
    padding: 0 38rpx;
    width: 674rpx;
    height: 300rpx;
    margin-top: -40rpx;
    z-index: 10;
    position: relative;
    .label {
      font-size: 28rpx;
      font-weight: 400;
      color: #999999;
    }
    .bas_info {
      width: 690rpx;
      height: 304rpx;
      background: #ffffff;
      box-shadow: 0rpx 6rpx 20rpx 1rpx rgba(32, 69, 97, 0.04);
      border-radius: 14rpx;
      overflow: hidden;
      .goods_name {
        margin-top: 40rpx;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        .name {
          font-size: 42rpx;
          font-weight: 600;
          color: #333333;
          text-align: center;
        }
        .unit {
          font-size: 28rpx;
          font-weight: 400;
          color: #016ef9;
        }
      }
      .t1 {
        text-align: center;
        font-size: 32rpx;
        font-weight: 600;
        color: #666666;
        margin-bottom: 10rpx;
      }
      .t2 {
        text-align: center;
        font-size: 26rpx;
        font-weight: 400;
        color: #999999;
      }
    }
    .code_box {
      margin-top: 16rpx;
      width: 642rpx;
      height: 252rpx;
      background: #ffffff;
      box-shadow: 0rpx 6rpx 20rpx 1rpx rgba(32, 69, 97, 0.04);
      border-radius: 14rpx;
      padding: 0 24rpx;
      flex-direction: column;
      .code_row {
        width: 100%;
        justify-content: space-between;
        flex: 1;
        align-items: center;
        border-bottom: #eff3f9 2rpx solid;
        .code {
          font-size: 28rpx;
          font-weight: 400;
          color: #666666;
        }
      }
    }
    .promotion {
      width: 650rpx;
      height: 48rpx;
      background: #ffffff;
      box-shadow: 0rpx 6rpx 20rpx 1rpx rgba(32, 69, 97, 0.04);
      border-radius: 14rpx;
      padding: 20rpx;
      margin-top: 16rpx;
      align-items: center;
      justify-content: space-between;
    }
    .price_box {
      margin-top: 16rpx;
      width: 650rpx;
      height: 457rpx;
      background: #ffffff;
      box-shadow: 0rpx 6rpx 20rpx 1rpx rgba(32, 69, 97, 0.04);
      border-radius: 14rpx;
      padding: 20rpx;
      .price_row {
        align-items: center;
        justify-content: space-between;
        margin-bottom: 20rpx;
        input {
          width: 533rpx;
          height: 60rpx;
          background: #eaedf1;
          border-radius: 10rpx;
          opacity: 0.6;
          text-align: right;
          padding: 0 20rpx;
          font-size: 28rpx;
          font-weight: 500;
          color: #666666;
        }
        .boxNum {
          width: 190rpx;
          height: 60rpx;
          background: #eaedf1;
          border-radius: 10rpx;
          opacity: 0.6;
          text-align: right;
          padding: 0 20rpx;
          font-size: 28rpx;
          font-weight: 500;
          color: #666666;
        }
      }
    }
  }
  .yellow {
    color: #ffb509 !important;
  }
  .select {
    color: black;
  }
  .not_select {
    color: #d4d4d4;
  }

  .tab_box {
    padding: 30rpx 10rpx;
    font-size: 38rpx;
    font-weight: bold;
    background: white;
  }
  .base_info_box {
    padding: 0 30rpx;
    background: white;
    flex: 1;
  }
  .more_info_box {
    padding: 0 30rpx;
    background: white;
    flex: 1;
  }
  .save_box {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100rpx;
    .save {
      background: #007aff;
      color: white;
      width: 90%;
      height: 80rpx;
      justify-content: center;
      align-items: center;
      display: flex;
      border-radius: 40rpx;
    }
  }
}
</style>
